﻿using System;
using System.Linq;
using Evpo.ContactData.Common;
using Evpo.ContactData.Data;
using System.Collections.Generic;

namespace Evpo.ContactData.ViewModel
{
    public class LinkedGroupEditViewModel : ContactViewModel
    {
        public LinkedGroupEditViewModel(ModelFactory factory, IConnection conn, int contactID):
            base(factory, conn)
        {
            ContactID = contactID;
        }

        #region Fields
        #endregion

        #region Properties
        public int ContactID
        {
            get;
            set;
        }
        #endregion

        #region Methods
        public List<IRelationshipType> RelationshipTypes()
        {
            return _relAdapter.RelationshipTypes().Cast<IRelationshipType>().ToList();
        }

        public void DeleteRelationship(int contactID, int relatedContactID)
        {
            _relAdapter.DeleteRelationship(contactID, relatedContactID);
        }

        public void SaveRelationship(IRelationship relationship)
        {
            _relAdapter.SaveRelationship((Relationship)relationship);
        }

        public IRelationship CreateRelationship()
        {
            IRelationship retVal = _factory.CreateRelationship();
            retVal.ContactID = ContactID;
            return retVal;
        }
        #endregion Methods
    }
}
